﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FantastPlatform.Framework.IModel;
using FantastPlatform.Framework.Model;
using FantastPlatform.Framework.Core;

namespace FantastPlatform.Framework.IService
{
    public interface IUserService : IDataService<IUser>
    {
        /// <summary>
        /// 获取用户有权操作的资源
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        IList<IResource> GetResource(int userId);
        /// <summary>
        /// 获取用户在某一资源的操作权限
        /// </summary>
        /// <param name="user">用户</param>
        /// <param name="resource">资源</param>
        /// <returns></returns>
        IList<IOperation> GetOperations(IUser user, IResource resource);
        /// <summary>
        /// 获取用户角色
        /// </summary>
        /// <param name="keywords">关键字</param>
        /// <param name="userId"></param>
        /// <param name="page"></param>
        /// <param name="pageSize"></param>
        /// <param name="totoalCount"></param>
        /// <param name="sorts">排序</param>
        /// <returns></returns>
        IList<IRole> GetRoles(string keywords,IList<Sort> sorts,int userId, int page, int pageSize, out int totoalCount);
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="code"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        IUser Login(string name, string password);
        /// <summary>
        /// 得到没有关联员工的用户
        /// </summary>
        /// <param name="page"></param>
        /// <param name="pageSize"></param>
        /// <param name="totoalCount"></param>
        /// <returns></returns>
        IList<IUser> LoadNotUsedUsers(string keywords,IList<Sort> sorts,int page, int pageSize, out int totoalCount);
        /// <summary>
        /// 得到指定角色下没有添加的用户
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        IList<IUser> LoadUsersNotExsit(string keywords,IList<Sort> sorts, int roleId, int page, int pageSize, out int totoalCount);
        /// <summary>
        /// 为用户添加角色
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="roleIds"></param>
        void AddRoles(int userId, IList<int> roleIds);
        /// <summary>
        /// 移除用户角色
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="roleIds"></param>
        void RemoveRoles(int userId, IList<int> roleIds);
    }
}